package com.daxia.bumall.util;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;

import com.daxia.bumall.model.User;

public class UserHelper {
    
    public static String getPushAlias(Long userId) {
        return "user" + userId;
    }
    
    public static String getPushTag(Long userId) {
        return "user_" + userId;
    }
    
    public static boolean isMobileUser(User user) {
        return StringUtils.isNotBlank(user.getMobile());
    }
    
    public static boolean isWeixinUser(User user) {
        return StringUtils.isNotBlank(user.getUnionid());
    }
    
    public static boolean isGpsValid(User user) {
        return user.getLatitude() != null 
                && user.getLongitude() != null 
                && user.getLastGpsUpdatedTime() != null
                && user.getLastGpsUpdatedTime().after(DateUtils.addHours(new Date(), -5));
    }
}
